## *** 通用的响应模型 author：zhaomin ***


from pydantic import BaseModel, Field
from typing import Optional, Any
from datetime import datetime
from zoneinfo import ZoneInfo

class SuccessResponse(BaseModel):
    """ 成功响应 """
    code: int = Field(default=200, description="HTTP 状态码")
    timestamp: str = Field(
        default_factory=lambda: datetime.now(ZoneInfo('Asia/Shanghai')).isoformat(),
        description="响应时间"
    )
    message: str = Field(default="Success", description="响应消息")
    remarks: Optional[str] = Field(default=None, description="备注信息")
    data: Optional[Any] = Field(default=None, description="响应数据")


class FailedResponse(BaseModel):
    """ 失败响应 """
    code: int = Field(..., description="HTTP 状态码")
    timestamp: str = Field(
        default_factory=lambda: datetime.now(ZoneInfo('Asia/Shanghai')).isoformat(),
        description="响应时间"
    )
    message: str = Field(..., description="错误消息")
    remarks: Optional[str] = Field(default=None, description="错误备注")
    data: Optional[Any] = Field(default=None, description="响应数据，通常为 null")

